// pages/teacher/student-data/student-data.js
Page({
  data: {
    currentTab: 0,
    tabs: ['学习概况', '课程数据', '学员列表'],
    // 学习概况数据
    overview: {
      totalStudents: 1234,
      todayActiveStudents: 89,
      avgCompletionRate: 68.5,
      avgStudyDuration: 45
    },
    // 课程数据
    courseStats: [
      {
        id: 1,
        courseName: '微信小程序开发实战',
        studentCount: 456,
        completionRate: 72,
        avgRating: 4.8,
        totalRevenue: 9120.00
      },
      {
        id: 2,
        courseName: 'Python数据分析与挖掘',
        studentCount: 380,
        completionRate: 65,
        avgRating: 4.7,
        totalRevenue: 7600.00
      }
    ],
    // 学员列表
    students: [
      {
        id: 1,
        name: '张同学',
        avatar: '/images/avatar1.jpg',
        courseName: '微信小程序开发实战',
        progress: 85,
        studyDuration: 120,
        lastStudyTime: '2025-10-28 10:30',
        status: 'active'
      },
      {
        id: 2,
        name: '李同学',
        avatar: '/images/avatar2.jpg',
        courseName: 'Python数据分析与挖掘',
        progress: 45,
        studyDuration: 60,
        lastStudyTime: '2025-10-27 20:15',
        status: 'normal'
      },
      {
        id: 3,
        name: '王同学',
        avatar: '/images/avatar3.jpg',
        courseName: '微信小程序开发实战',
        progress: 20,
        studyDuration: 30,
        lastStudyTime: '2025-10-20 16:00',
        status: 'inactive'
      }
    ],
    // 筛选条件
    selectedCourse: 0,
    courseList: [
      { id: 0, name: '全部课程' },
      { id: 1, name: '微信小程序开发实战' },
      { id: 2, name: 'Python数据分析与挖掘' }
    ]
  },
  onLoad() {},
  switchTab(e) {
    this.setData({
      currentTab: e.currentTarget.dataset.index
    })
  },
  selectCourse(e) {
    this.setData({
      selectedCourse: e.detail.value
    })
  },
  viewStudentDetail(e) {
    const studentId = e.currentTarget.dataset.id
    wx.showToast({
      title: '查看学员详情',
      icon: 'none'
    })
  },
  exportData() {
    wx.showLoading({ title: '导出中...' })
    setTimeout(() => {
      wx.hideLoading()
      wx.showToast({
        title: '导出成功',
        icon: 'success'
      })
    }, 1500)
  }
})
